package com.sf.novatar.sample.redis;

import com.sf.iisp.util.HttpRequest;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.net.URLCodec;
import org.junit.Test;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by qi on 16-7-22.
 */
public class DigestTestCase {

    @Test
    public void testDigestParam() throws URISyntaxException, DecoderException, EncoderException {
        Map<String, String> params = new HashMap<>();
        params.put("Operation", "1");
        params.put("CorpId", "886293");
        params.put("User", "admin");
        params.put("Pwd", "cinteam123");
        params.put("ObjId", "2016");
        params.put("DataType", "data");
        params.put("DataKey", "Telparser");
        params.put("WhereStr", "transId");
        params.put("DataSpace", "05200200");

        URI uri = HttpRequest.getUrl("58.220.61.26:8078/dataInterface/action.do", params);
        System.out.println(uri);
        byte[] bytes = URLCodec.decodeUrl(uri.toString().getBytes());
        String md5Str = DigestUtils.sha384Hex(uri.toString());

        URLCodec uc = new URLCodec();
        String decodeStr =uc.encode(uri.toString());
        System.out.println(decodeStr);
    }
}
